package com.gong.bank.service;

import com.gong.bank.dao.BankDaoImpl;
import com.gong.bank.dao.BankDaoInterface;
import com.gong.bank.factory.LogBean;
import com.gong.bank.model.UserBean;

import java.sql.ResultSet;
import java.util.List;

/**
 * @description:
 * @author:gong
 * @create: 4/8/2022 上午9:12
 */
public class BankServiceImpl implements BankService{
    BankDaoInterface bankDao = new BankDaoImpl();
    @Override
    public void saveMoney(double money, UserBean user) {
        bankDao.saveMoney(money,user);
    }

    @Override
    public void insertUser(String username, String password) {
        bankDao.insertUser(username, password);
    }

    @Override
    public void deleteMoney(double money, UserBean user) {
        bankDao.deleteMoney(money, user);
    }

    @Override
    public UserBean findUserByName(String username) {
        return bankDao.findUserByName(username);
    }

    @Override
    public double getMoney(String userName) {
        return bankDao.getMoney(userName);
    }

    @Override
    public void delete(String username) {
        bankDao.delete(username);
    }

    @Override
    public int updateAdmin(UserBean user, int admin) {
        return bankDao.updateAdmin(user, admin);
    }

    @Override
    public int insertLog(UserBean userBean, String operation, double money) {
        bankDao.insertLog(userBean,operation,money);
        return 0;
    }

    @Override
    public List<LogBean> selectAllLog() {
        return bankDao.selectAllLog();
    }

    public static void main(String[] args) {
        BankServiceImpl bankService = new BankServiceImpl();
        UserBean userBean = new UserBean();
        userBean.setId(6);
        userBean.setUsername("fang");
        userBean.setPassword("123");
        userBean.setMoney(10);
        userBean.setAdmin(0);
        bankService.insertUser("fang","123");
//        bankService.insertLog(userBean,"查询",10);
    }
}
